package pkg

import (
	"encoding/json"
	"fmt"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

func CheckText(text string) bool {
	client := censor.NewClient("lkxm4EDzR5k5J93q7SbwnmE9", "mqcczPNID10NNbLZRgacUkvmHUFsONYC")
	////如果是百度云ak sk,使用下面的客户端
	//client=censor.NewCloudClient("ak","sk")
	res := client.TextCensor(text)
	fmt.Println(res)

	var result CheckTestResult
	json.Unmarshal([]byte(res), &result)

	fmt.Println(result)

	return result.ConclusionType == 1

}

type CheckTestResult struct {
	ConclusionType int `json:"ConclusionType"`
}
